﻿// CButtonEx.cpp: 实现文件
//

#include "pch.h"
#include "Draw.h"
#include "CButtonEx.h"


// CButtonEx

IMPLEMENT_DYNAMIC(CButtonEx, CButton)

CButtonEx::CButtonEx()
{

}

CButtonEx::~CButtonEx()
{
}


BEGIN_MESSAGE_MAP(CButtonEx, CButton)
END_MESSAGE_MAP()



// CButtonEx 消息处理程序




void CButtonEx::DrawItem(LPDRAWITEMSTRUCT lpDIS)
{
	CRect rect = lpDIS->rcItem;
	CDC dc;
	dc.Attach(lpDIS->hDC);

	// 就式样的预置的绘制控件框架的函数
	/*UINT uStyle = DFCS_BUTTONPUSH;
	if (lpDIS->itemState & ODS_SELECTED) {
		uStyle |= DFCS_PUSHED;
	}
	dc.DrawFrameControl(rect, DFC_BUTTON, uStyle);*/

	if (lpDIS->itemState & ODS_SELECTED) {
		dc.FillSolidRect(rect, RGB(202, 200, 207));
	}
	else {
		dc.FillSolidRect(rect, RGB(202, 232, 207));
	}

	CString str;
	GetWindowText(str);
	CFont font;
	font.CreatePointFont(12 * 10, _T("微软雅黑"));// 字号*10
	dc.SelectObject(&font);
	dc.DrawText(str, rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
	
	dc.Detach();
}
